﻿///<reference path="class.ts" /> 
//previous comment is to make reference to another ts file

module TypeScriptingStuff {
    // Interface
    export interface IEntity {
        getId(): number;
    }

    // Inheritance and Interface Implementation
    export class Employee extends Person implements IEntity {

        constructor(public firstName: string, public lastName: string, public employeeId: number) {
            super(firstName, lastName);
            Employee.instanceCount++;
        }

        public static instanceCount: number;

        getId(): number { //public by default
            return this.employeeId;
        }

        public getFullName(): string {
            return this.firstName + " "
                + this.lastName + " (" + this.employeeId + ")";
        }
    }

    // Polymorphism
    class Program {
        static assertEquals(expected: any, actual: any, message?: string): void { //message is optional parameter
            if (expected !== actual)
                throw "Expected: " + expected + "\nActual: " + actual + "\n" + message;
        }

        static main() {
            var employee: Employee;
            var person: Person;
            employee = new Employee("Inigo", "Montoya", 42);
            Program.assertEquals(employee.getId(), 42);
            person = employee;
            Program.assertEquals(person.getFullName(), "Inigo Montoya (42)",
                "The person.getFullName() was not what was expected.");
        }
    }
}